<template>
  <div class="header">
    <div class="header-left">
      <div class="iconfont back-icon">&#xe624;</div>
    </div>
    <div class="header-input">
      <span class="iconfont serach-icon">&#xe632;</span>
      <span>输入城市/景点/游玩主题</span>
    </div>
    <router-link to="/city">
      <div class="header-right">
        <!-- <span>{{this.doubleCity}}</span> -->
        <span>{{this.city}}</span>
        <span class="iconfont arrow-icon">&#xe6aa;</span>
      </div>
    </router-link>
  </div>
</template>
<script>
import { mapState } from 'vuex'
export default {
  name: 'HomeHeader',
  computed: {
    // 把vuex中的数据映射到当前组件的computed计算属性里
    // ...mapState({ city: state => state.city })
    // 映射 this.city 为 store.state.city
    // 辅助函数
    ...mapState(['city'])
    // ...mapGetters(['doubleCity'])
  }
}
</script>

<style lang="stylus" scoped>
// 1rem = html font-size = 50px
// 样式npm install stylus --save
@import '~styles/varibles.styl';

.header {
  display: flex;
  height: $headerHeight;
  line-height: $headerHeight;
  background: $bgColor;
  align-items: center;
  color: #fff;

  .header-left {
    width: 0.72rem;
    float: left;

    .back-icon {
      text-align: center;
      font-size: 0.36rem;
    }
  }

  .header-input {
    flex: 1;
    height: 0.64rem;
    line-height: 0.64rem;
    background-color: #fff;
    border-radius: 0.1rem;
    // margin-top: 0.12rem;
    color: #ccc;

    .serach-icon {
      margin: 0rem 0.2rem;
    }
  }

  .header-right {
    min-width: 1.04rem;
    // flex: 1;
    padding: 0 0.1rem;
    float: right;
    text-align: center;
    color: #fff;

    .arrow-icon {
      margin-left: -0.08rem;
    }
  }
}
</style>
